﻿@{
    ViewData["Title"] = "添加PLC点位配置";
    Layout = "_Edit";
}
<article class="page-container">
    <form action="" method="post" class="form form-horizontal" id="form-add">
        <input type="hidden" class="input-text" value="@Model.ID" id="id" name="id">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>提升机编号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.ElevatorCode" placeholder="请输入提升机编号" id="ElevatorCode" name="ElevatorCode">
            </div>
        </div>
        
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>十字口设备编号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.CrossroadCode" placeholder="请输入十字口设备编号" id="CrossroadCode" name="CrossroadCode">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>标签名：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.ItemName" placeholder="请输入标签名" id="ItemName" name="ItemName">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>标签值：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.ItemValue" placeholder="请输入标签值" id="ItemValue" name="ItemValue">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>点位（地址）：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.Address" placeholder="请输入点位" id="Address" name="Address">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>数据类型：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.DataType" placeholder="请输数据类型" id="DataType" name="DataType">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>楼层：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.Floor" placeholder="请输入楼层" id="Floor" name="Floor">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>PLC连接IP：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
                    <select class="select" size="1" name="PlcConnectionId" id="PlcConnectionId">
                        <option value="0">--请选择--</option>
                        @foreach (var item in Model.PlcIpSearchs)
                        {
                            if (Model.PlcConnectID + "" == item.PlcConnectId)
                            {
                                <option value="@item.PlcConnectId" selected>@item.PlcConnectIp</option>
                            }
                            else
                            {
                                <option value="@item.PlcConnectId">@item.PlcConnectIp</option>
                            }
                        }
                    </select>
                </span>
            </div>
        </div>
        
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="button" onclick="operate()" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

@section javascript{

<script>
    $('.skin-minimal input').iCheck({
         checkboxClass: 'icheckbox-blue',
         radioClass: 'iradio-blue',
         increaseArea: '20%'
     });
     function operate(){
         

          var ElevatorCode=$("#ElevatorCode").val();
         if(ElevatorCode==null||ElevatorCode=="")
         {
            popupAlert('请输入提升机编号',2,function(data){layer.close(data);});
           return;
         }

         var CrossroadCode=$("#CrossroadCode").val();
         if(CrossroadCode==null||CrossroadCode=="")
         {
            popupAlert('请输入十字口设备编号',2,function(data){layer.close(data);});
           return;
         }
         
         var ItemName=$("#ItemName").val();
         if(ItemName==null||ItemName=="")
         {
            popupAlert('请输入标签名',2,function(data){layer.close(data);});
           return;
         }
         var ItemValue=$("#ItemValue").val();
         if(ItemValue==null||ItemValue=="")
         {
            popupAlert('请输入标签值',2,function(data){layer.close(data);});
           return;
         }
         var Address=$("#Address").val();
         if(Address==null||Address=="")
         {
            popupAlert('请输入点位',2,function(data){layer.close(data);});
           return;
         }
         var DataType=$("#DataType").val();
         if(DataType==null||DataType=="")
         {
            popupAlert('请输入数据类型',2,function(data){layer.close(data);});
           return;
         }
         var Floor=$("#Floor").val();
         if(Floor==null||Floor=="")
         {
            popupAlert('请输入楼层',2,function(data){layer.close(data);});
           return;
         }
         var PlcConnectionId=$("#PlcConnectionId").val();
         if(PlcConnectionId==null||PlcConnectionId==""||PlcConnectionId==0)
         {
            popupAlert('请选择PLC连接IP',2,function(data){layer.close(data);});
           return;
         }
        SubmitFormForAjax("/plcpointinfo/operateplcpointinfo", $("#form-add").serialize(), function (data) {
            if (data.result) {
                    popupAlert('提交成功',1,function(){closePageLayer(true);});
            }else{
                popupAlert(data.message,2,function(data){layer.close(data);});
            }
        },true);
     }
</script>
}